home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of MacTutor - S…e Code for Volumes 1 to 5
/
The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin
/
Source Code
/
#49 (Oct 89)
/
DMP Source
/
src
/
PACK.c
< prev
next >
Wrap
Text File
|
1989-01-02
|
2KB
|
100 lines
/*
* Chooser Device Package code. Described in the Device Manager
* chapter of Inside Macintosh IV.
*/
/*
* Earle R. Horton.
* Wednesday, November 30, 1988
* All rights reserved.
*/
#include <Resources.h>
#include <ToolUtils.h>
#include <OSUtils.h>
#include <Dialogs.h>
#include <Lists.h>
#define PACK
#include "dmp-110.h"
#include "compat.h"
#define __SEG__ Main
/*
* The Pascal Interface to MPW C 2.0.2 does not fully include the List Manager.
*/
#ifdef macintosh
pascal void LGetCell(Ptr,short *,Cell,ListHandle);
pascal void LSetCell(Ptr,short,Cell,ListHandle);
pascal void LSetSelect(Boolean,Cell,ListHandle);
#endif
pascal OSErr device(message,caller,objname,zonename,p1,p2)
short message,caller;
StringPtr objname,zonename;
long p1,p2;
{
Pfg settings;
#ifndef BACKWARD_COMPATIBLE
SysEnvRec World;
(void)SysEnvirons(1,&World);
if(World.systemVersion < SYSNEEDED){
(void)StopAlert(SYSVERSALERT,nil);
}
else
#endif
switch(message){
case buttonMsg:
prsetup(p2);
break;
case fillListMsg:
filllist(p1);
break;
case selectMsg:
settings = (Pfg)(GetResource('HEXA',RES2ID));
pbaud = p2;
break;
}
return (noErr);
}
/*
* Fill the list passed to us with the names of baud rates contained
* in our 'STR#' resource.
*/
filllist(list)
ListHandle list;
{
Pfg settings;
Cell cell;
short i;
char thestring[256];
settings = (Pfg)(GetResource('HEXA',RES2ID));
(void)LAddRow(11,0,list);
for(i=0;i<11;){
SetPt(&cell,0,i++);
GetIndString(thestring,RES1ID,i);
LSetCell(&thestring[1],(short)thestring[0],cell,list);
}
SetPt(&cell,0,pbaud);
LSetSelect(0xFFFF,cell,list);
LAutoScroll(list);
}
/*
* prsetup() - Configure serial port.
*/
prsetup(button)
long button;
{
Pfg settings;
if ((settings = (Pfg)(GetResource('HEXA',RES2ID))) == nil)
return;
if((button & 0xFF) == 1){
if(IsMPPOpen()){ /* Conflict! */
(void)StopAlert(ATALKALERT,nil);
return;
}
pport = 1;
}else{
pport = 0;
}
ChangedResource(settings);
WriteResource(settings);
}